<cfcomponent extends="Model">
	<cffunction name="init">
		<cfscript>
			qryDocumentURL = "CASE
													WHEN type = 'Insurance' AND documents.id = 9 THEN 'eligibilityReferralAdmission'
													WHEN type = 'Insurance' AND documents.id = 8 THEN 'consent'
													WHEN type = 'Insurance' AND documents.id = 6 THEN 'rightsResponsibilities'
													WHEN type = 'Insurance' AND documents.id = 7 THEN 'rulesRegulations'
													WHEN type = 'Insurance' AND documents.id = 5 THEN 'universal'
													WHEN type = 'Insurance' AND documents.id = 4 THEN 'advanceDirective'
													
													WHEN type = 'Doctor' AND documents.id = 10 THEN 'evaluation'
													WHEN type = 'Assessment' AND documents.id = 11 THEN 'assessment'

													WHEN type = 'Discharge' AND documents.id = 12 THEN 'discharge'
								
													WHEN type = 'Medication' AND documents.id = 13 THEN 'controlledSubstance'
													WHEN type = 'Medication' AND documents.id = 14 THEN 'vitalSigns'
								 					WHEN type = 'Medication' AND documents.id = 15 THEN 'routineLog'
													WHEN type = 'Medication' AND documents.id = 16 THEN 'orders'
													WHEN type = 'Medication' AND documents.id = 17 THEN 'prnLog'
								
													WHEN type = 'ITP' AND documents.id = 1 THEN 'dailySummary'
								 					WHEN type = 'ITP' AND documents.id = 2 THEN 'individualTreatmentPlan'
													WHEN type = 'ITP' AND documents.id = 3 THEN 'groupNotes'
													ELSE ''
												END";

			qryDocumentSortOrder = "CASE 
																WHEN type = 'Insurance' 		THEN 1
																WHEN type = 'Doctor' 			THEN 2
																WHEN type = 'Assessment' 	THEN 3
																WHEN type = 'ITP' 					THEN 4
																WHEN type = 'Medication'		THEN 5
																ELSE 6
															END";
			
			property(name="documentSortOrder", sql=qryDocumentSortOrder);
			property(name="documentAction", sql=qryDocumentURL);
			hasMany("insurance");
			hasMany("doctor");
			hasMany("medication");
			hasMany("assessment");
			hasMany("itp");
			hasMany("discharge");
			belongsTo("consumer");
		</cfscript>
	</cffunction>
</cfcomponent>